#!/bin/bash

usage="Usage: ExtractBinaryRules.sh file_type tree_type xorder xrel cs_input binary_rules"

if [ $# -lt 6 ]
then
	echo "Error: incorrect number of arguments."
	echo $usage
	exit
fi

script_dir=$(dirname $0)
file_type=$1
tree_type=$2
xorder=$3
xrel=$4
cs_input=$5
binary_rules=$6

if [ $xorder -eq 1 ]
then
	xorder_flag="-xorder"
elif [ $xorder -eq 0 ]
then
	xorder_flag=""
else
	echo "Error: value for xorder argument must be either 0 or 1"
	echo $usage
	exit
fi

if [ $xrel -eq 1 ]
then
	xrel_flag="-xrel"
elif [ $xrel -eq 0 ]
then
	xrel_flag=""
else
	echo "Error: value for xrel argument must be either 0 or 1"
	echo $usage
	exit
fi

java -cp $script_dir/../../bin:$script_dir/../../jars/gems-2009.11-bin.jar proc.ExtractBinaryRules -filetype $file_type -treetype $tree_type $xorder_flag $xrel_flag $cs_input $binary_rules
